package tas.co.in.controller.employees;

import java.util.List;
import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.sun.org.apache.xpath.internal.operations.Bool;

import tas.co.in.dao.employees.DailyTaskConnect;
import tas.co.in.domain.employees.DailyTaskBean;

public class DailyTaskController extends MultiActionController 
{
	
	private DailyTaskConnect dailyTaskConnect ;

	/**
	 * @param dailyTaskConnect the dailyTaskConnect to set
	 */
	public void setDailyTaskConnect(DailyTaskConnect dailyTaskConnect) {
		this.dailyTaskConnect = dailyTaskConnect;
	}
	
	public ModelAndView SetDailyTask(HttpServletRequest request,
			HttpServletResponse response)
	{
		HttpSession  httpSession=request.getSession(true);
		
		String userID=httpSession.getAttribute("userName").toString();
		
		DailyTaskBean taskBean=new DailyTaskBean();
		taskBean.setTaskAssignBy(userID);
		
		StringTokenizer tokenizer =new StringTokenizer(request.getParameter("tasklist"),",");
		
		Boolean boolean1=dailyTaskConnect.setTasks(tokenizer,taskBean);
		
		DailyTaskBean resultsBean=new DailyTaskBean();
		resultsBean.setResult(boolean1);
		
		return new ModelAndView("sharedJSP/task","resultObject",resultsBean) ;
	}
	
	public ModelAndView getDailyTask(HttpServletRequest request,
			HttpServletResponse response)
	{
		HttpSession session=request.getSession(true);
		
		DailyTaskBean bean=new DailyTaskBean();
		bean.setTaskCity(request.getParameter("taskCity"));
		
		List<DailyTaskBean> resultList=dailyTaskConnect.getAllTaskList(bean);
		
		return new ModelAndView("sharedJSP/viewtasks","resultList",resultList);
		
	}

}
